/**
 * Title: BaseThreadPool.java
 * Description:
 * Copyright: Copyright (c) 2008
 * Company:深圳彩讯科技有限公司
 * Author 罗旭东 (hi@luoxudong.com)
 * Date 2013-8-12 下午3:55:46
 * Version 1.0 
 */
package com.luoxudong.phonenumber.service.pool.manager;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import android.os.Build;

/** 
 * ClassName: BaseThreadPool 
 * Description:基础线程池
 * Create by 罗旭东
 * Date 2013-8-12 下午3:55:46 
 */
public class BaseThreadPool extends ThreadPoolExecutor {
	public BaseThreadPool(ThreadPoolParams threadPoolParamter)
	{
		super(threadPoolParamter.getCorePoolSize(), 
			  threadPoolParamter.getMaximumPoolSize(), 
			  threadPoolParamter.getKeepAliveTime(), 
			  TimeUnit.MILLISECONDS, //线程池维护线程所允许的空闲时间的单位
			  new ArrayBlockingQueue<Runnable>(threadPoolParamter.getPoolQueueSize()), //线程池所使用的缓冲队列
			  new ThreadPoolExecutor.CallerRunsPolicy());//线程池对拒绝任务的处理策略,重试添加当前的任务，他会自动重复调用execute()方法
		if (Build.VERSION.SDK_INT > 10) {
			this.allowCoreThreadTimeOut(threadPoolParamter.isAllowCoreThreadTimeOut());
		}

	}
}
